<template>
  <div class="home">
    <el-row :gutter="20" class="welcome-section">
      <el-col :span="24">
        <el-card class="welcome-card">
          <div class="welcome-content">
            <h1>欢迎使用Vue沙盒测试平台</h1>
            <p>这是一个专为后端API练习设计的前端平台，提供完整的接口测试和沙盒环境</p>
            <el-button type="primary" size="large" @click="startTesting">
              开始测试
            </el-button>
          </div>
        </el-card>
      </el-col>
    </el-row>

    <el-row :gutter="20" class="features-section">
      <el-col :xs="24" :sm="12" :md="8" v-for="feature in features" :key="feature.title">
        <el-card class="feature-card" shadow="hover">
          <div class="feature-icon">
            <el-icon :size="40" :color="feature.color">
              <component :is="feature.icon" />
            </el-icon>
          </div>
          <h3>{{ feature.title }}</h3>
          <p>{{ feature.description }}</p>
        </el-card>
      </el-col>
    </el-row>

    <el-row :gutter="20" class="quick-start-section">
      <el-col :span="24">
        <el-card class="quick-start-card">
          <template #header>
            <div class="card-header">
              <span>快速开始</span>
            </div>
          </template>
          <el-steps :active="1" align-center>
            <el-step title="选择接口" description="浏览接口文档，选择合适的API进行测试" />
            <el-step title="配置参数" description="设置请求参数、请求头和认证信息" />
            <el-step title="发送请求" description="发送请求并查看响应结果" />
            <el-step title="分析结果" description="分析响应数据，调试和优化" />
          </el-steps>
        </el-card>
      </el-col>
    </el-row>
  </div>
</template>

<script setup>
import { useRouter } from 'vue-router'
import { 
  Monitor, 
  Connection, 
  Setting, 
  Document,
  DataAnalysis,
  Tools
} from '@element-plus/icons-vue'

const router = useRouter()

const features = [
  {
    title: 'API测试',
    description: '完整的HTTP请求测试工具，支持GET、POST、PUT、DELETE等所有方法',
    icon: 'Connection',
    color: '#409EFF'
  },
  {
    title: '沙盒环境',
    description: '安全的代码执行环境，支持多种编程语言的代码测试',
    icon: 'Setting',
    color: '#67C23A'
  },
  {
    title: '接口文档',
    description: '详细的API接口文档，包含请求参数、响应格式和示例代码',
    icon: 'Document',
    color: '#E6A23C'
  },
  {
    title: '实时监控',
    description: '实时监控API调用状态，查看请求日志和性能指标',
    icon: 'Monitor',
    color: '#F56C6C'
  },
  {
    title: '数据分析',
    description: '强大的数据分析工具，帮助理解API响应和调试问题',
    icon: 'DataAnalysis',
    color: '#909399'
  },
  {
    title: '开发工具',
    description: '丰富的开发工具，提升API开发和测试效率',
    icon: 'Tools',
    color: '#9C27B0'
  }
]

const startTesting = () => {
  router.push('/api-test')
}
</script>

<style scoped>
.home {
  max-width: 1200px;
  margin: 0 auto;
}

.welcome-section {
  margin-bottom: 40px;
}

.welcome-card {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
}

.welcome-content {
  text-align: center;
  padding: 40px 20px;
}

.welcome-content h1 {
  font-size: 2.5rem;
  margin-bottom: 20px;
  font-weight: 600;
}

.welcome-content p {
  font-size: 1.2rem;
  margin-bottom: 30px;
  opacity: 0.9;
}

.features-section {
  margin-bottom: 40px;
}

.feature-card {
  text-align: center;
  padding: 30px 20px;
  height: 100%;
  transition: all 0.3s ease;
}

.feature-card:hover {
  transform: translateY(-5px);
}

.feature-icon {
  margin-bottom: 20px;
}

.feature-card h3 {
  color: #303133;
  margin-bottom: 15px;
  font-size: 1.3rem;
}

.feature-card p {
  color: #606266;
  line-height: 1.6;
}

.quick-start-section {
  margin-bottom: 40px;
}

.quick-start-card {
  background-color: #f8f9fa;
}

.card-header {
  font-size: 1.2rem;
  font-weight: 600;
  color: #303133;
}

/* 响应式设计 */
@media (max-width: 768px) {
  .welcome-content h1 {
    font-size: 2rem;
  }
  
  .welcome-content p {
    font-size: 1rem;
  }
  
  .feature-card {
    margin-bottom: 20px;
  }
}
</style>
